using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Attributes.DomainAttributes;
using Baci.Net.ToolKit.ArcGISProGeoprocessor.Models.Enums;
using System.Collections.Generic;
using System.ComponentModel;

namespace Baci.ArcGIS._DataManagementTools._Fields
{
    /// <summary>
    /// <para>Calculate Field</para>
    /// <para>Calculates the values of a field for a feature class, feature layer, or raster.</para>
    /// <para>计算要素类、要素图层或栅格的字段值。</para>
    /// </summary>    
    [DisplayName("Calculate Field")]
    public class CalculateField : AbstractGPProcess
    {
        /// <summary>
        /// 无参构造
        /// </summary>
        public CalculateField()
        {

        }

        /// <summary>
        /// 有参构造
        /// </summary>
        /// <param name="_in_table">
        /// <para>Input Table</para>
        /// <para>The table containing the field that will be updated with the new calculation.</para>
        /// <para>包含将使用新计算更新的字段的表。</para>
        /// </param>
        /// <param name="_field">
        /// <para>Field Name (Existing or New)</para>
        /// <para><xdoc>
        ///   <para>The field that will be updated with the new calculation.</para>
        ///   <para>If a field with the specified name does not exist in the input table, it will be added.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>将使用新计算更新的字段。</para>
        ///   <para>如果输入表中不存在具有指定名称的字段，则将添加该字段。</para>
        /// </xdoc></para>
        /// </param>
        /// <param name="_expression">
        /// <para>Expression</para>
        /// <para>The simple calculation expression used to create a value that will populate the selected rows.</para>
        /// <para>用于创建将填充所选行的值的简单计算表达式。</para>
        /// </param>
        public CalculateField(object _in_table, object _field, object _expression)
        {
            this._in_table = _in_table;
            this._field = _field;
            this._expression = _expression;
        }
        public override string ToolboxName => "Data Management Tools";

        public override string ToolName => "Calculate Field";

        public override string CallName => "management.CalculateField";

        public override List<string> AcceptEnvironments => ["extent", "transferDomains", "workspace"];

        public override object[] ParameterInfo => [_in_table, _field, _expression, _expression_type.GetGPValue(), _code_block, _out_table, _field_type.GetGPValue(), _enforce_domains.GetGPValue()];

        /// <summary>
        /// <para>Input Table</para>
        /// <para>The table containing the field that will be updated with the new calculation.</para>
        /// <para>包含将使用新计算更新的字段的表。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Input Table")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _in_table { get; set; }


        /// <summary>
        /// <para>Field Name (Existing or New)</para>
        /// <para><xdoc>
        ///   <para>The field that will be updated with the new calculation.</para>
        ///   <para>If a field with the specified name does not exist in the input table, it will be added.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>将使用新计算更新的字段。</para>
        ///   <para>如果输入表中不存在具有指定名称的字段，则将添加该字段。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Field Name (Existing or New)")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _field { get; set; }


        /// <summary>
        /// <para>Expression</para>
        /// <para>The simple calculation expression used to create a value that will populate the selected rows.</para>
        /// <para>用于创建将填充所选行的值的简单计算表达式。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Expression")]
        [Description("")]
        [Option(OptionTypeEnum.Must)]
        public object _expression { get; set; }


        /// <summary>
        /// <para>Expression Type</para>
        /// <para><xdoc>
        ///   <para>Specifies the type of expression that will be used.</para>
        ///   <bulletList>
        ///     <bullet_item>Python 3—The Python expression type will be used. This is the default.</bullet_item><para/>
        ///     <bullet_item>Arcade—The Arcade expression type will be used.</bullet_item><para/>
        ///     <bullet_item>SQL—The SQL expression type will be used.</bullet_item><para/>
        ///   </bulletList>
        ///   <para>To learn more about Python expressions, see Calculate Field Python examples.</para>
        ///   <para>To learn more about Arcade expressions, see the ArcGIS Arcade guide.</para>
        ///   <para>To learn more about SQL expressions, see Calculate field values.</para>
        ///   <para>SQL expressions support faster calculations for feature services and enterprise geodatabases. Instead of performing calculations one feature or row at a time, a single request is set to the server or database, resulting in significantly faster calculations.</para>
        ///   <para>Only feature services and enterprise geodatabases support SQL expressions. For other formats, use Python or Arcade expressions.</para>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定将使用的表达式的类型。</para>
        ///   <bulletList>
        ///     <bullet_item>Python 3 - 将使用 Python 表达式类型。这是默认设置。</bullet_item><para/>
        ///     <bullet_item>Arcade—将使用 Arcade 表达式类型。</bullet_item><para/>
        ///     <bullet_item>SQL—将使用 SQL 表达式类型。</bullet_item><para/>
        ///   </bulletList>
        ///   <para>若要了解有关 Python 表达式的详细信息，请参阅计算字段 Python 示例。</para>
        ///   <para>要了解有关 Arcade 表达式的详细信息，请参阅 ArcGIS Arcade 指南。</para>
        ///   <para>若要了解有关 SQL 表达式的详细信息，请参阅计算字段值。</para>
        ///   <para>SQL 表达式支持对要素服务和企业级地理数据库进行更快的计算。无需一次执行一个要素或行的计算，而是将单个请求设置为服务器或数据库，从而大大加快了计算速度。</para>
        ///   <para>只有要素服务和企业级地理数据库支持 SQL 表达式。对于其他格式，请使用 Python 或 Arcade 表达式。</para>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Expression Type")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _expression_type_value _expression_type { get; set; } = _expression_type_value._PYTHON3;

        public enum _expression_type_value
        {
            /// <summary>
            /// <para>Python 3</para>
            /// <para>Python 3—The Python expression type will be used. This is the default.</para>
            /// <para>Python 3 - 将使用 Python 表达式类型。这是默认设置。</para>
            /// </summary>
            [Description("Python 3")]
            [GPEnumValue("PYTHON3")]
            _PYTHON3,

            /// <summary>
            /// <para>Arcade</para>
            /// <para>Arcade—The Arcade expression type will be used.</para>
            /// <para>Arcade—将使用 Arcade 表达式类型。</para>
            /// </summary>
            [Description("Arcade")]
            [GPEnumValue("ARCADE")]
            _ARCADE,

            /// <summary>
            /// <para>SQL</para>
            /// <para>SQL—The SQL expression type will be used.</para>
            /// <para>SQL—将使用 SQL 表达式类型。</para>
            /// </summary>
            [Description("SQL")]
            [GPEnumValue("SQL")]
            _SQL,

        }

        /// <summary>
        /// <para>Code Block</para>
        /// <para>A block of code that will be entered for complex expressions.</para>
        /// <para>将为复杂表达式输入的代码块。</para>
        /// <para></para>
        /// </summary>
        [DisplayName("Code Block")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public object _code_block { get; set; } = null;


        /// <summary>
        /// <para>Updated Input Table</para>
        /// <para></para>
        /// <para></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Updated Input Table")]
        [Description("")]
        [Option(OptionTypeEnum.derived)]
        public object _out_table { get; set; }


        /// <summary>
        /// <para>Field Type</para>
        /// <para><xdoc>
        ///   <para>Specifies the field type of the new field. This parameter is only used when the field name does not exist in the input table.</para>
        ///   <para>If the field is of type text, the new field will have a length of 512. For shapefiles and dBASE files, the field will have a length of 254. The length of the new field can be adjusted using the Alter Field tool.</para>
        ///   <bulletList>
        ///     <bullet_item>Text—Any string of characters can be used.</bullet_item><para/>
        ///     <bullet_item>Float (single precision)— Fractional numbers between -3.4E38 and 1.2E38 can be used.</bullet_item><para/>
        ///     <bullet_item>Double (double precision)— Fractional numbers between -2.2E308 and 1.8E308 can be used.</bullet_item><para/>
        ///     <bullet_item>Short (small integer)— Whole numbers between -32,768 and 32,767 can be used.</bullet_item><para/>
        ///     <bullet_item>Long (large integer)— Whole numbers between -2,147,483,648 and 2,147,483,647 can be used.</bullet_item><para/>
        ///     <bullet_item>Date—Date and time will be used.</bullet_item><para/>
        ///     <bullet_item>Blob (binary data)—A long sequence of binary numbers will be used.</bullet_item><para/>
        ///     <bullet_item>Raster imagery—Raster images will be used. All ArcGIS software-supported raster dataset formats can be stored; however, it is recommended that you use only small images.</bullet_item><para/>
        ///     <bullet_item>GUID (globally unique identifier)—A globally unique identifier will be used.</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定新字段的字段类型。仅当输入表中不存在字段名称时，才使用此参数。</para>
        ///   <para>如果字段类型为 text，则新字段的长度为 512。对于 shapefile 和 dBASE 文件，字段的长度为 254。可以使用“更改字段”工具调整新字段的长度。</para>
        ///   <bulletList>
        ///     <bullet_item>文本 - 可以使用任何字符串。</bullet_item><para/>
        ///     <bullet_item>浮点数（单精度）— 可以使用介于 -3.4E38 和 1.2E38 之间的小数。</bullet_item><para/>
        ///     <bullet_item>双精度（双精度）— 可以使用介于 -2.2E308 和 1.8E308 之间的小数。</bullet_item><para/>
        ///     <bullet_item>短（小整数）— 可以使用介于 -32,768 和 32,767 之间的整数。</bullet_item><para/>
        ///     <bullet_item>长整数（大整数）— 可以使用介于 -2,147,483,648 和 2,147,483,647 之间的整数。</bullet_item><para/>
        ///     <bullet_item>日期—将使用日期和时间。</bullet_item><para/>
        ///     <bullet_item>Blob（二进制数据）- 将使用一长串二进制数。</bullet_item><para/>
        ///     <bullet_item>栅格影像—将使用栅格影像。可以存储所有 ArcGIS 软件支持的栅格数据集格式;但是，建议您仅使用小图像。</bullet_item><para/>
        ///     <bullet_item>GUID（全局唯一标识符）- 将使用全局唯一标识符。</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Field Type")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _field_type_value _field_type { get; set; } = _field_type_value._TEXT;

        public enum _field_type_value
        {
            /// <summary>
            /// <para>Text</para>
            /// <para>Text—Any string of characters can be used.</para>
            /// <para>文本 - 可以使用任何字符串。</para>
            /// </summary>
            [Description("Text")]
            [GPEnumValue("TEXT")]
            _TEXT,

            /// <summary>
            /// <para>Float (single precision)</para>
            /// <para>Float (single precision)— Fractional numbers between -3.4E38 and 1.2E38 can be used.</para>
            /// <para>浮点数（单精度）— 可以使用介于 -3.4E38 和 1.2E38 之间的小数。</para>
            /// </summary>
            [Description("Float (single precision)")]
            [GPEnumValue("FLOAT")]
            _FLOAT,

            /// <summary>
            /// <para>Double  (double precision)</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("Double  (double precision)")]
            [GPEnumValue("DOUBLE")]
            _DOUBLE,

            /// <summary>
            /// <para>Short (small integer)</para>
            /// <para>Short (small integer)— Whole numbers between -32,768 and 32,767 can be used.</para>
            /// <para>短（小整数）— 可以使用介于 -32,768 和 32,767 之间的整数。</para>
            /// </summary>
            [Description("Short (small integer)")]
            [GPEnumValue("SHORT")]
            _SHORT,

            /// <summary>
            /// <para>Long (large integer)</para>
            /// <para>Long (large integer)— Whole numbers between -2,147,483,648 and 2,147,483,647 can be used.</para>
            /// <para>长整数（大整数）— 可以使用介于 -2,147,483,648 和 2,147,483,647 之间的整数。</para>
            /// </summary>
            [Description("Long (large integer)")]
            [GPEnumValue("LONG")]
            _LONG,

            /// <summary>
            /// <para>Date</para>
            /// <para>Date—Date and time will be used.</para>
            /// <para>日期—将使用日期和时间。</para>
            /// </summary>
            [Description("Date")]
            [GPEnumValue("DATE")]
            _DATE,

            /// <summary>
            /// <para>Blob (binary data)</para>
            /// <para>Blob (binary data)—A long sequence of binary numbers will be used.</para>
            /// <para>Blob（二进制数据）- 将使用一长串二进制数。</para>
            /// </summary>
            [Description("Blob (binary data)")]
            [GPEnumValue("BLOB")]
            _BLOB,

            /// <summary>
            /// <para>Raster imagery</para>
            /// <para>Raster imagery—Raster images will be used. All ArcGIS software-supported raster dataset formats can be stored; however, it is recommended that you use only small images.</para>
            /// <para>栅格影像—将使用栅格影像。可以存储所有 ArcGIS 软件支持的栅格数据集格式;但是，建议您仅使用小图像。</para>
            /// </summary>
            [Description("Raster imagery")]
            [GPEnumValue("RASTER")]
            _RASTER,

            /// <summary>
            /// <para>GUID (globally unique identifier)</para>
            /// <para>GUID (globally unique identifier)—A globally unique identifier will be used.</para>
            /// <para>GUID（全局唯一标识符）- 将使用全局唯一标识符。</para>
            /// </summary>
            [Description("GUID (globally unique identifier)")]
            [GPEnumValue("GUID")]
            _GUID,

        }

        /// <summary>
        /// <para>Enforce Domains</para>
        /// <para><xdoc>
        ///   <para>Specifies whether field domain rules will be enforced.</para>
        ///   <bulletList>
        ///     <bullet_item>Checked—Field domain rules will be enforced. If a field cannot be updated, the field value will remain unchanged, and the tool messages will include a warning message.</bullet_item><para/>
        ///     <bullet_item>Unchecked—Field domain rules will not be enforced. This is the default</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para><xdoc>
        ///   <para>指定是否强制执行字段域规则。</para>
        ///   <bulletList>
        ///     <bullet_item>选中 - 将强制执行字段域规则。如果字段无法更新，则字段值将保持不变，并且工具消息将包含警告消息。</bullet_item><para/>
        ///     <bullet_item>未选中 - 将不强制执行字段域规则。这是默认设置</bullet_item><para/>
        ///   </bulletList>
        /// </xdoc></para>
        /// <para></para>
        /// </summary>
        [DisplayName("Enforce Domains")]
        [Description("")]
        [Option(OptionTypeEnum.optional)]
        public _enforce_domains_value _enforce_domains { get; set; } = _enforce_domains_value._false;

        public enum _enforce_domains_value
        {
            /// <summary>
            /// <para>ENFORCE_DOMAINS</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("ENFORCE_DOMAINS")]
            [GPEnumValue("true")]
            _true,

            /// <summary>
            /// <para>NO_ENFORCE_DOMAINS</para>
            /// <para></para>
            /// <para></para>
            /// </summary>
            [Description("NO_ENFORCE_DOMAINS")]
            [GPEnumValue("false")]
            _false,

        }

        public CalculateField SetEnv(object extent = null, bool? transferDomains = null, object workspace = null)
        {
            base.SetEnv(extent: extent, transferDomains: transferDomains, workspace: workspace);
            return this;
        }

    }

}